package com.nondo.dean.dealer.controller.wap.app;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.nondo.dean.common.web.View;
import com.nondo.dean.dealer.model.result.StoreResult;
import com.nondo.dean.dealer.service.StoreService;

@Controller("apiWapStore")
@RequestMapping("/wap/app/store")
public class StoreController {

    @Value("${baseUrl}")
    private String baseUrl;

    @Autowired
    private StoreService storeService;

    /**
     * 经销商店铺预览
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/view")
    public ModelAndView userStoreView(HttpServletRequest request, HttpServletResponse response) {
        ModelAndView mv = new ModelAndView("wap/app/store/info");
        mv.addObject("baseUrl", baseUrl);
        return mv;
    }
    
    @ResponseBody
    @RequestMapping("/info/{id}")
    public View<StoreResult> getStoreDetail(HttpServletRequest request,HttpServletResponse response, @PathVariable("id") Integer id){
        View<StoreResult> view = new View<StoreResult>(20000, "查看成功");
        StoreResult result =null;
        result = storeService.userStorePreview(id,request);
        if (result == null) {
            result = new StoreResult();
        }
        view.setData(result);

        return view;
    }

}